// Package store
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2024 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.7
package store

import (
	"context"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"

	"github.com/gogf/gf/v2/frame/g"
)

// StoreProductAttrUpdateFields 修改商品属性字段过滤
type StoreProductAttrUpdateFields struct {
	Name  string `json:"name"  dc:"属性名称"`
	Value string `json:"value" dc:"属性值"`
}

// StoreProductAttrInsertFields 新增商品属性字段过滤
type StoreProductAttrInsertFields struct {
	Name  string `json:"name"  dc:"属性名称"`
	Value string `json:"value" dc:"属性值"`
}

// StoreProductAttrEditInp 修改/新增商品属性
type StoreProductAttrEditInp struct {
	entity.StoreProductAttr
}

func (in *StoreProductAttrEditInp) Filter(ctx context.Context) (err error) {
	// 验证属性名称
	if err := g.Validator().Rules("required").Data(in.Name).Messages("属性名称不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证属性值
	if err := g.Validator().Rules("required").Data(in.Value).Messages("属性值不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	return
}

type StoreProductAttrEditModel struct{}

// StoreProductAttrDeleteInp 删除商品属性
type StoreProductAttrDeleteInp struct {
	Id interface{} `json:"id" v:"required#主键id不能为空" dc:"主键id"`
}

func (in *StoreProductAttrDeleteInp) Filter(ctx context.Context) (err error) {
	return
}

type StoreProductAttrDeleteModel struct{}

// StoreProductAttrViewInp 获取指定商品属性信息
type StoreProductAttrViewInp struct {
	Id int `json:"id" v:"required#主键id不能为空" dc:"主键id"`
}

func (in *StoreProductAttrViewInp) Filter(ctx context.Context) (err error) {
	return
}

type StoreProductAttrViewModel struct {
	entity.StoreProductAttr
}

// StoreProductAttrListInp 获取商品属性列表
type StoreProductAttrListInp struct {
	form.PageReq
	Id int `json:"id" dc:"主键id"`
}

func (in *StoreProductAttrListInp) Filter(ctx context.Context) (err error) {
	return
}

type StoreProductAttrListModel struct {
	Id        int    `json:"id"        dc:"主键id"`
	ProductId int    `json:"productId" dc:"商品id"`
	Name      string `json:"name"      dc:"属性名称"`
	Value     string `json:"value"     dc:"属性值"`
}

// StoreProductAttrExportModel 导出商品属性
type StoreProductAttrExportModel struct {
	Id        int    `json:"id"        dc:"主键id"`
	ProductId int    `json:"productId" dc:"商品id"`
	Name      string `json:"name"      dc:"属性名称"`
	Value     string `json:"value"     dc:"属性值"`
}
